Hide the mouse cursor in the completion feedback window
authorFederico Mena Quintero <federico@novell.com>
Fri, 14 Mar 2008 02:45:44 +0000 (02:45 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Fri, 14 Mar 2008 02:45:44 +0000 (02:45 +0000)
2008-03-13  Federico Mena Quintero  <federico@novell.com>

* gtk/gtkfilechooserentry.c (create_completion_feedback_window):
Set the mouse cursor of the feedback window to invisible, so that
we respect GtkEntry's invisible cursor while typing.

Signed-off-by: Federico Mena Quintero <federico@gnu.org>
svn path=/trunk/; revision=19870

ChangeLog
gtk/gtkfilechooserentry.c

index c8587be97a362fc8c5ea4ea8823cf13d6e262f86..1d80d6eb0976c4585b0e150a1e15924df9f827eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-13  Federico Mena Quintero  <federico@novell.com>
+
+       * gtk/gtkfilechooserentry.c (create_completion_feedback_window):
+       Set the mouse cursor of the feedback window to invisible, so that
+       we respect GtkEntry's invisible cursor while typing.
+
 2008-03-13  Federico Mena Quintero  <federico@novell.com>
 
        * gtk/gtkfilechooserentry.c (show_completion_feedback_window): Put
index c97fb08fc3979b8f9d3277d074bcd64a5f6f91ab..afcb5bf20ab95a5862778488bf28644c5a263be4 100644 (file)
@@ -850,6 +850,47 @@ completion_feedback_window_expose_event_cb (GtkWidget      *widget,
   return FALSE;
 }
 
+static void
+set_invisible_mouse_cursor (GdkWindow *window)
+{
+  /* Stolen from gtkentry.c:set_invisible_cursor() */
+  /* FIXME: implement a stupid public gdk_window_set_invisible_mouse_cursor() */
+
+  GdkBitmap *empty_bitmap;
+  GdkCursor *cursor;
+  GdkColor useless;
+  char invisible_cursor_bits[] = { 0x0 };
+
+  useless.red = useless.green = useless.blue = 0;
+  useless.pixel = 0;
+
+  empty_bitmap = gdk_bitmap_create_from_data (window,
+                                             invisible_cursor_bits,
+                                             1, 1);
+
+  cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
+                                      empty_bitmap,
+                                      &useless,
+                                      &useless, 0, 0);
+
+  gdk_window_set_cursor (window, cursor);
+
+  gdk_cursor_unref (cursor);
+
+  g_object_unref (empty_bitmap);
+}
+
+static void
+completion_feedback_window_realize_cb (GtkWidget *widget,
+                                      gpointer data)
+{
+  /* We hide the mouse cursor inside the completion feedback window, since
+   * GtkEntry hides the cursor when the user types.  We don't want the cursor to
+   * come back if the completion feedback ends up where the mouse is.
+   */
+  set_invisible_mouse_cursor (widget->window);
+}
+
 static void
 create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
 {
@@ -875,6 +916,9 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
 
   g_signal_connect (chooser_entry->completion_feedback_window, "expose_event",
                    G_CALLBACK (completion_feedback_window_expose_event_cb), chooser_entry);
+  g_signal_connect (chooser_entry->completion_feedback_window, "realize",
+                   G_CALLBACK (completion_feedback_window_realize_cb), chooser_entry);
+  /* FIXME: connect to motion-notify-event, and *show* the cursor when the mouse moves */
 
   chooser_entry->completion_feedback_label = gtk_label_new (NULL);
   gtk_container_add (GTK_CONTAINER (alignment), chooser_entry->completion_feedback_label);